﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PublicType
{
    /// <summary>
    /// 数据返回
    /// </summary>
    /// <typeparam name="T">返回数据格式</typeparam>
    public class ReturnData
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public Boolean IsSuccess { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public String Message { get; set; }
        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData SuccessResult(String Message = "")
        {
            ReturnData Result = new ReturnData();
            Result.IsSuccess = true;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData FailResult(String Message = "")
        {
            ReturnData Result = new ReturnData();
            Result.IsSuccess = false;
            Result.Message = Message;
            return Result;
        }
    }
    /// <summary>
    /// 数据返回
    /// </summary>
    /// <typeparam name="T">返回数据格式</typeparam>
    public class ReturnData<T>
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public Boolean IsSuccess { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public String Message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T Data { get; set; }
        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T> SuccessResult(T t, String Message = "")
        {
            ReturnData<T> Result = new ReturnData<T>();
            Result.IsSuccess = true;
            Result.Data = t;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T> FailResult(T t, String Message = "")
        {
            ReturnData<T> Result = new ReturnData<T>();
            Result.IsSuccess = false;
            Result.Data = t;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T> FailResult(String Message = "")
        {
            ReturnData<T> Result = new ReturnData<T>();
            Result.IsSuccess = false;
            Result.Data = default(T);
            Result.Message = Message;
            return Result;
        }
    }
    /// <summary>
    /// 数据返回
    /// </summary>
    /// <typeparam name="T1">返回数据格式</typeparam>
    /// <typeparam name="T2">返回数据格式</typeparam>
    public class ReturnData<T1, T2>
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public Boolean IsSuccess { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public String Message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T1 Data1 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T2 Data2 { get; set; }
        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2> SuccessResult(T1 t1, T2 t2, String Message = "")
        {
            ReturnData<T1, T2> Result = new ReturnData<T1, T2>();
            Result.IsSuccess = true;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2> FailResult(T1 t1, T2 t2, String Message = "")
        {
            ReturnData<T1, T2> Result = new ReturnData<T1, T2>();
            Result.IsSuccess = false;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Message = Message;
            return Result;
        }
    }
    /// <summary>
    /// 数据返回
    /// </summary>
    /// <typeparam name="T1">返回数据格式</typeparam>
    /// <typeparam name="T2">返回数据格式</typeparam>
    /// <typeparam name="T3">返回数据格式</typeparam>
    public class ReturnData<T1, T2, T3>
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public Boolean IsSuccess { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public String Message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T1 Data1 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T2 Data2 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T3 Data3 { get; set; }
        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3> SuccessResult(T1 t1, T2 t2, T3 t3, String Message = "")
        {
            ReturnData<T1, T2, T3> Result = new ReturnData<T1, T2, T3>();
            Result.IsSuccess = true;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3> FailResult(T1 t1, T2 t2, T3 t3, String Message = "")
        {
            ReturnData<T1, T2, T3> Result = new ReturnData<T1, T2, T3>();
            Result.IsSuccess = false;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Message = Message;
            return Result;
        }
    }
    /// <summary>
    /// 数据返回
    /// </summary>
    /// <typeparam name="T1">返回数据格式</typeparam>
    /// <typeparam name="T2">返回数据格式</typeparam>
    /// <typeparam name="T3">返回数据格式</typeparam>
    /// <typeparam name="T4">返回数据格式</typeparam>
    public class ReturnData<T1, T2, T3, T4>
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public Boolean IsSuccess { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public String Message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T1 Data1 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T2 Data2 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T3 Data3 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T4 Data4 { get; set; }
        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3, T4> SuccessResult(T1 t1, T2 t2, T3 t3, T4 t4, String Message = "")
        {
            ReturnData<T1, T2, T3, T4> Result = new ReturnData<T1, T2, T3, T4>();
            Result.IsSuccess = true;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Data4 = t4;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3, T4> FailResult(T1 t1, T2 t2, T3 t3, T4 t4, String Message = "")
        {
            ReturnData<T1, T2, T3, T4> Result = new ReturnData<T1, T2, T3, T4>();
            Result.IsSuccess = false;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Data4 = t4;
            Result.Message = Message;
            return Result;
        }
    }
    /// <summary>
    /// 数据返回
    /// </summary>
    /// <typeparam name="T1">返回数据格式</typeparam>
    /// <typeparam name="T2">返回数据格式</typeparam>
    /// <typeparam name="T3">返回数据格式</typeparam>
    /// <typeparam name="T4">返回数据格式</typeparam>
    /// <typeparam name="T5">返回数据格式</typeparam>
    public class ReturnData<T1, T2, T3, T4, T5>
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public Boolean IsSuccess { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public String Message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T1 Data1 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T2 Data2 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T3 Data3 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T4 Data4 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T5 Data5 { get; set; }
        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3, T4, T5> SuccessResult(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, String Message = "")
        {
            ReturnData<T1, T2, T3, T4, T5> Result = new ReturnData<T1, T2, T3, T4, T5>();
            Result.IsSuccess = true;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Data4 = t4;
            Result.Data5 = t5;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3, T4, T5> FailResult(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, String Message = "")
        {
            ReturnData<T1, T2, T3, T4, T5> Result = new ReturnData<T1, T2, T3, T4, T5>();
            Result.IsSuccess = false;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Data4 = t4;
            Result.Data5 = t5;
            Result.Message = Message;
            return Result;
        }
    }
    /// <summary>
    /// 数据返回
    /// </summary>
    /// <typeparam name="T1">返回数据格式</typeparam>
    /// <typeparam name="T2">返回数据格式</typeparam>
    /// <typeparam name="T3">返回数据格式</typeparam>
    /// <typeparam name="T4">返回数据格式</typeparam>
    /// <typeparam name="T5">返回数据格式</typeparam>
    /// <typeparam name="T6">返回数据格式</typeparam>
    public class ReturnData<T1, T2, T3, T4, T5, T6>
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public Boolean IsSuccess { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public String Message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T1 Data1 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T2 Data2 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T3 Data3 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T4 Data4 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T5 Data5 { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T6 Data6 { get; set; }

        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3, T4, T5, T6> SuccessResult(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, String Message = "")
        {
            ReturnData<T1, T2, T3, T4, T5, T6> Result = new ReturnData<T1, T2, T3, T4, T5, T6>();
            Result.IsSuccess = true;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Data4 = t4;
            Result.Data5 = t5;
            Result.Data6 = t6;
            Result.Message = Message;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static ReturnData<T1, T2, T3, T4, T5, T6> FailResult(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, String Message = "")
        {
            ReturnData<T1, T2, T3, T4, T5, T6> Result = new ReturnData<T1, T2, T3, T4, T5, T6>();
            Result.IsSuccess = false;
            Result.Data1 = t1;
            Result.Data2 = t2;
            Result.Data3 = t3;
            Result.Data4 = t4;
            Result.Data5 = t5;
            Result.Data6 = t6;
            Result.Message = Message;
            return Result;
        }
    }

    //public static class ReturnDataExtensions
    //{
    //    public static String ToEasyUiDataGridData<T>(this ReturnData<List<T>> returnData)
    //    {
    //        EasyUiDataGridData easyUiDataGridData = new EasyUiDataGridData();
    //        easyUiDataGridData.msg = returnData.Message;
    //        easyUiDataGridData.result = returnData.IsSuccess;
    //        easyUiDataGridData.rows = returnData.Data as List<Object>;
    //        //easyUiDataGridData.total
    //        return easyUiDataGridData.Serialize();
    //    }
    //}    
    #region EasyUiDataGrid数据返回类型


    public class EasyUiDataGridData<T>
    {
        public string msg { get; set; }

        public bool result { get; set; }

        public List<T> rows { get; set; }

        public int total { get; set; }

        public static EasyUiDataGridData<T> SuccessResult(PagingData<T> pagingData, String Message = "")
        {
            EasyUiDataGridData<T> Result = new EasyUiDataGridData<T>();
            Result.result = true;
            Result.msg = Message;
            Result.rows = pagingData.Data;
            Result.total = pagingData.Total;
            return Result;
        }
        public static EasyUiDataGridData<T> SuccessResult(List<T> rows, String Message = "")
        {
            EasyUiDataGridData<T> Result = new EasyUiDataGridData<T>();
            Result.result = true;
            Result.msg = Message;
            Result.rows = rows;
            Result.total = rows.Count;
            return Result;
        }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static EasyUiDataGridData<T> FailResult(String Message = "")
        {
            EasyUiDataGridData<T> Result = new EasyUiDataGridData<T>();
            Result.result = false;
            Result.msg = Message;
            return Result;
        }
    }
    public class EasyUiDataGridData
    {
        public string msg { get; set; }

        public bool result { get; set; }

        public int total { get; set; }

        public List<Object> rows { get; set; }
        /// <summary>
        /// 操作失败
        /// </summary>
        /// <param name="t">数据</param>
        /// <param name="Message">消息</param>
        /// <returns></returns>
        public static EasyUiDataGridData FailResult(String Message = "")
        {
            EasyUiDataGridData Result = new EasyUiDataGridData();
            Result.result = false;
            Result.msg = Message;
            return Result;
        }
    }
    #endregion
}
